jQuery(function($){
	$('.arrow-down').on('click',function(event){
		event.preventDefault();
		var t = $(this);

		if( ! t.data('section') ) {
			var id = '#' + $('#main section:first').attr('id');
			scrollTo(id);
		}
	});
	/**
	 * Scroll to section
	 * @param  string des HTML identity of section block
	 * @return void
	 */
	function scrollTo(des){
		var os = (history.pushState)?51:0;
		os = (jQuery(window).width()>800)?os:0;

		var pos = (jQuery(des).length>0 )?jQuery(des).offset().top-os:0;
		onanimate = true;
		jQuery('html,body').animate({scrollTop:pos},1000,function(){
			if(history.pushState){
				history.pushState(null,null,des);
			}else		window.location.hash = des;
			jQuery(window).scrollTop(pos);
			onanimate=false
		});
	}
});